package com.matriq.cloudmanager.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.matriq.cloudmanager.MyApp;
import com.matriq.cloudmanager.entity.Comment;
import com.matriq.cloudmanager.entity.Console;
import com.matriq.cloudmanager.entity.CourseInfo;
import com.matriq.cloudmanager.entity.MyMessage;
import com.matriq.cloudmanager.entity.MyScoreInfo;
import com.matriq.cloudmanager.entity.Notice;

import net.lgpage.http.HttpMsg;
import net.lgpage.http.ServiceUtil2;

public class CourseService {

	private static CourseService service;

	private CourseService() {
		super();
	}

	public static CourseService getService() {
		if (service == null)
			service = new CourseService();
		return service;
	}
	/**
	 * 咨询列表接口
	 * @param type 咨询类型
	 * @param pageNo 页码
	 * @param pageMax 每页最大数
	 * @return
	 * @throws Exception
	 */
	public List<Console> console(String type,Integer pageNo,Integer pageMax) throws Exception {
		Map<String, String> map = new HashMap<String, String>();
		map.put("type", type);
		
map.put("pageNo", pageNo+"");
map.put("pageMax", pageMax+"");
		return ServiceUtil2.getListByMapFromHttpMsg("console", "POST", map, Console.class);
	}
	/**
	 * 评论列表接口
	 * @param console_id 咨询ID
	 * @param pageNo 页码
	 * @param pageMax 每页最大数
	 * @return
	 * @throws Exception
	 */
	public List<Comment> console_comment(String console_id,Integer pageNo,Integer pageMax) throws Exception {
		Map<String, String> map = new HashMap<String, String>();
		map.put("console_id", console_id);
		
map.put("pageNo", pageNo+"");
map.put("pageMax", pageMax+"");
		return ServiceUtil2.getListByMapFromHttpMsg("console/comment", "POST", map, Comment.class);
	}
	/**
	 * 对咨询评论接口
	 * @param console_id 咨询ID
	 * @param content 评论内容
	 * @param no 学员编号
	 * @return
	 * @throws Exception
	 */
	public HttpMsg console_comment_add(String console_id,String content,String no) throws Exception {
		Map<String, String> map = new HashMap<String, String>();
		map.put("console_id", console_id);
		
		map.put("content", content);
		
		map.put("no", MyApp.getApp().getUsername());

		return ServiceUtil2.getObjByMapFromHttpMsg("console/comment/add", "POST", map, HttpMsg.class);
	}
	/**
	 * 对咨询点赞接口
	 * @param console_id 咨询ID
	 * @param no 学员编号
	 * @return
	 * @throws Exception
	 */
	public HttpMsg console_zan(String console_id,String no) throws Exception {
		Map<String, String> map = new HashMap<String, String>();
		map.put("console_id", console_id);
		
		map.put("no", MyApp.getApp().getUsername());

		return ServiceUtil2.getObjByMapFromHttpMsg("console/zan", "POST", map, HttpMsg.class);
	}
	/**
	 * 通知公告列表接口
	 * @param no 学员id
	 * @param pageNo 页码
	 * @param pageMax 每页最大数
	 * @return
	 * @throws Exception
	 */
	public List<Notice> notice(String no,Integer pageNo,Integer pageMax) throws Exception {
		Map<String, String> map = new HashMap<String, String>();
		map.put("no", MyApp.getApp().getUsername());

map.put("pageNo", pageNo+"");
map.put("pageMax", pageMax+"");
		return ServiceUtil2.getListByMapFromHttpMsg("notice", "POST", map, Notice.class);
	}
	/**
	 * 我的消息列表接口
	 * @param no 学员id
	 * @param pageNo 页码
	 * @param pageMax 每页最大数
	 * @return
	 * @throws Exception
	 */
	public List<MyMessage> mymessage(String no,Integer pageNo,Integer pageMax) throws Exception {
		Map<String, String> map = new HashMap<String, String>();
		map.put("no", MyApp.getApp().getUsername());

map.put("pageNo", pageNo+"");
map.put("pageMax", pageMax+"");
		return ServiceUtil2.getListByMapFromHttpMsg("mymessage", "POST", map, MyMessage.class);
	}
	/**
	 * 我的课程接口
	 * @param no 学员id
	 * @param type 类型0选修，1必修，2推荐
	 * @param pageNo 页码
	 * @param pageMax 每页最大数
	 * @return
	 * @throws Exception
	 */
	public List<CourseInfo> mycourse(String no,String type,Integer pageNo,Integer pageMax) throws Exception {
		Map<String, String> map = new HashMap<String, String>();
		map.put("no", MyApp.getApp().getUsername());

		map.put("type", type);
		
map.put("pageNo", pageNo+"");
map.put("pageMax", pageMax+"");
		return ServiceUtil2.getListByMapFromHttpMsg("mycourse", "POST", map, CourseInfo.class);
	}
	/**
	 * 课程评论列表接口
	 * @param course_id 课程ID
	 * @param pageNo 页码
	 * @param pageMax 每页最大数
	 * @return
	 * @throws Exception
	 */
	public List<Comment> course_comment(String course_id,Integer pageNo,Integer pageMax) throws Exception {
		Map<String, String> map = new HashMap<String, String>();
		map.put("course_id", course_id);
		
map.put("pageNo", pageNo+"");
map.put("pageMax", pageMax+"");
		return ServiceUtil2.getListByMapFromHttpMsg("course/comment", "POST", map, Comment.class);
	}
	/**
	 * 对课程评价接口
	 * @param course_id 咨询ID
	 * @param content 评论内容
	 * @param no 学员编号
	 * @return
	 * @throws Exception
	 */
	public HttpMsg course_comment_add(String course_id,String content,String no) throws Exception {
		Map<String, String> map = new HashMap<String, String>();
		map.put("course_id", course_id);
		
		map.put("content", content);
		
		map.put("no", MyApp.getApp().getUsername());

		return ServiceUtil2.getObjByMapFromHttpMsg("course/comment/add", "POST", map, HttpMsg.class);
	}
	/**
	 * 对课程点赞接口
	 * @param course_id 课程ID
	 * @param no 学员编号
	 * @return
	 * @throws Exception
	 */
	public HttpMsg course_zan(String course_id,String no) throws Exception {
		Map<String, String> map = new HashMap<String, String>();
		map.put("course_id", course_id);
		
		map.put("no", MyApp.getApp().getUsername());

		return ServiceUtil2.getObjByMapFromHttpMsg("course/zan", "POST", map, HttpMsg.class);
	}
	/**
	 * 我的学分接口
	 * @param no 学员编号
	 * @return
	 * @throws Exception
	 */
	public MyScoreInfo myscore(String no) throws Exception {
		Map<String, String> map = new HashMap<String, String>();
		map.put("no", MyApp.getApp().getUsername());

		return ServiceUtil2.getObjByMapFromHttpMsg("myscore", "POST", map, MyScoreInfo.class);
	}
	
	
}
